<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var findComplement = function(num) {
				const toTwo = num.toString(2);
				const str = String(toTwo);
				let endStr = "";
				for (let i = 0; i < str.length; i++) {
					endStr += str[i] == "1" ? "0" : "1";
				};
				return parseInt(endStr, 2);
			};
			console.log(findComplement(5));
		</script>
	</body>
</html>
